package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.supervision.dto.create.JzdxIdentityCreateDTO;
import com.engine4cloud.tdf.supervision.dto.update.JzdxIdentityUpdateDTO;
import com.engine4cloud.tdf.supervision.entity.JzdxIdentityEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public interface JzdxIdentityConvert {
    JzdxIdentityConvert INSTANCE = Mappers.getMapper(JzdxIdentityConvert.class);

    @Mapping(target = "id", ignore = true)
    JzdxIdentityEntity createTo(JzdxIdentityCreateDTO s);

    JzdxIdentityEntity update(JzdxIdentityUpdateDTO s);

    JzdxIdentityCreateDTO updateCreate(JzdxIdentityUpdateDTO s);

    default JzdxIdentityEntity create(JzdxIdentityCreateDTO s, String code, Long tenantId) {
        JzdxIdentityEntity entity = createTo(s);
        entity.setRybh(code);
        entity.setTenantId(tenantId);
        return entity;
    }
}
